package com.lib.common.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.viewpager.widget.ViewPager;

/**
 * @author 一叶丶枫凌
 * 描述：
 * Created on 2018-02-07 9:48
 */
public class NoScrollViewPager extends ViewPager {

    private boolean mScrollAble;

    public NoScrollViewPager(Context context) {

        super(context);
    }

    public NoScrollViewPager(Context context, AttributeSet attrs) {

        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {

        return mScrollAble && super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        return mScrollAble && super.onTouchEvent(ev);
    }

    public void setScrollAble(boolean scrollAble) {

        mScrollAble = scrollAble;
    }
}